﻿@{
                /**/

                ViewBag.Title = "Register";
                Layout = null;
}

<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <title>周游企业管理平台--注册</title>
    <link rel="icon" type="image/png" sizes="16x16" href="~/res/assets/images/favicon.png">
    <title>Material Pro Admin Template - The Most Complete & Trusted Bootstrap 4 Admin Template</title>
    <!-- Bootstrap Core CSS -->
    <link href="~/res/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="~/res/css/style.css" rel="stylesheet">
    <!-- You can change the theme colors from here -->
    <link href="~/res/css/colors/blue.css" id="theme" rel="stylesheet">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" />
        </svg>
    </div>
    <!-- ============================================================== -->
    <!-- Main wrapper - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <section id="wrapper" class="login-register login-sidebar" style="background-image:url(../res/assets/images/background/login-register.jpg);">
        <div class="login-box card">
            <div class="card-body">
                <form class="form-horizontal form-material" id="loginform" action="index.html">
                    <a href="javascript:void(0)" class="text-center db"><img src="../res/assets/images/logo-icon.png" alt="Home" /><br /><img src="../res/assets/images/logo-text.png" alt="Home" /></a>
                    <h3 class="box-title m-t-40 m-b-0">Sign Up</h3>
                    <div class="form-group ">
                        <div class="col-xs-12">
                            <div class="input-group">

                                <input type="email" id="InEmail" class="form-control" required="" placeholder="邮箱">
                                <span class="input-group-btn">
                                    <button id="SendBt" class="btn btn-primary btn-lg btn-block text-uppercase waves-effect waves-light">发送验证码</button>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-xs-12">
                            <input id="InCode" class="form-control" type="text" placeholder="验证码" required="" maxlength="4" disabled>
                        </div>
                    </div>

                    <div class="form-group ">
                        <div class="col-xs-12">
                            <input id="InPhone" class="form-control" type="text" required="" placeholder="手机号码">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-xs-12">
                            <input id="InName" class="form-control" type="text" required="" placeholder="姓名">
                        </div>
                    </div>
                    <div class="form-group ">
                        <div class="col-xs-12">
                            <input class="form-control" id="PAS" type="password" required="" placeholder="密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-xs-12">
                            <input class="form-control" id="PASTWO" type="password" required="" placeholder="确认密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-12">
                            <div class="checkbox checkbox-success p-t-0 p-l-10">
                                <input id="checkbox-signup" type="checkbox">
                                <label for="checkbox-signup"> 我已阅读并接受 <a href="#">《周游用户服务协议》</a></label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group text-center m-t-20">
                        <div class="col-xs-12">
                            <button id="RegBt" class="btn btn-info btn-lg btn-block text-uppercase waves-effect waves-light" type="submit">注册</button>
                        </div>
                    </div>
                    <div class="form-group m-b-0">
                        <div class="col-sm-12 text-center">
                            <p>
                                已经有账户了? <a href="../Home/login" class="text-info m-l-5"><b>返回登录</b></a>
                            </p>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </section>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="~/res/assets/plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="~/res/assets/plugins/bootstrap/js/popper.min.js"></script>
    <script src="~/res/assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="~/res/js/jquery.slimscroll.js"></script>
    <!--Wave Effects -->
    <script src="~/res/js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="~/res/js/sidebarmenu.js"></script>
    <!--stickey kit -->
    <script src="~/res/assets/plugins/sticky-kit-master/dist/sticky-kit.min.js"></script>
    <script src="~/res/assets/plugins/sparkline/jquery.sparkline.min.js"></script>
    <!--Custom JavaScript -->
    <script src="~/res/js/custom.min.js"></script>
    <!-- ============================================================== -->
    <!-- Style switcher -->
    <!-- ============================================================== -->
    <script src="~/res/assets/plugins/styleswitcher/jQuery.style.switcher.js"></script>
    <link href="~/res/assets/plugins/sweetalert/sweetalert.css" rel="stylesheet" type="text/css">
    <script src="~/res/assets/plugins/sweetalert/sweetalert.min.js"></script>
    <script>
        $(function () {

            var interval = null;
            var RecoverTime = 60;
            $("#SendBt").click(function () {
                if ($("#InEmail").val() == "") {
                    swal("提示!", "请填写邮箱");
                    return;
                }
                $("#SendBt").html("验证码发送中...");
                $("#SendBt").attr('disabled', true);
                $.post("../Home/login?act=SendCode&reg=reg", { Mail: $("#InEmail").val() },
                    function (data) {
                        data = JSON.parse(data);
                        if (data.status === 0) {
                            $("#SendBt").attr('disabled', true);
                            $("#InCode").attr('disabled', false);                            
                            interval = setInterval(RecoverTimeFu, 1000);
                            $("#InCode").focus();
                        } else {
                            $("#SendBt").html("发送验证码");
                            $("#SendBt").attr('disabled', false);
                            swal("发送失败!", data.message);
                            return false;
                        }
                    });

                return false;
            });

            function RecoverTimeFu() {
                RecoverTime = RecoverTime - 1;
                $("#SendBt").html(RecoverTime);
                if (RecoverTime === 0) {
                    clearInterval(interval);
                    interval = null;
                    $("#SendBt").html("发送验证码");
                    $("#SendBt").attr('disabled', false);
                }
            }


            $("#loginform").submit(function (e) {
                if (!$("#checkbox-signup").prop('checked')) {
                    swal("提示", "未同意用户协议");
                    return false;
                }
                if ($("#PAS").val().length < 6) {
                    swal("提示!", "密码长度小于6位");
                    return false;
                }
                if ($("#PAS").val() !== $("#PASTWO").val()) {
                    swal("提示!", "两次密码不一致");
                    return false;
                }

                $("#RegBt").html("注册中，请稍后...");
                $("#RegBt").attr('disabled', true);
                $.post("../Home/Register?act=Reg", {
                    Mail: $("#InEmail").val(),
                    InCode: $("#InCode").val(),
                    PAS: $("#PAS").val(),
                    InPhone: $("#InPhone").val(),
                    InName: $("#InName").val()
                },
                    function (data) {
                        data = JSON.parse(data);
                        $("#RegBt").removeAttr("disabled");
                        if (data.status === 0) {

                            swal({
                                title: "注册成功!",
                                text: "将在2秒后退回登录窗口.",
                                timer: 2000,
                                showConfirmButton: false
                            }, function () {
                                window.setTimeout(function () {
                                    window.location.href = "../Home/login";
                                }, 500);
                            });

                        } else {
                            $("#RegBt").html("注册");
                            swal("注册失败!", data.message);
                            return false;
                        }
                    });
                return false;
            });
        });
    </script>

</body>
</html>
